package com.jams.goodox.activity.mine.interaction;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jams.goodox.BaseFragment;
import com.jams.goodox.R;
import com.jams.goodox.adapter.CustomFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Jin on 2016/7/5.
 * Description 我的互动-我参与的
 */
public class MineInteractionJoinFragment extends BaseFragment {

	@Bind(R.id.tabLayout)
    TabLayout tabLayout;
	@Bind(R.id.viewPager)
    ViewPager viewPager;

	private List<Fragment> fragmentList;
	private List<String> tabsTitle;

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.mine_interaction_join, container, false);
		ButterKnife.bind(this, rootView);

		//我报名的
		Fragment fragment1 = new MineInteraction3Fragment();
		//评论我的
		Fragment fragment2 = new MineCommentFragment();
		//我推荐的
		RecommendFragment fragment3 = new RecommendFragment();
		fragmentList = new ArrayList<>();
		tabsTitle = new ArrayList<>();

		fragmentList.add(fragment1);
		tabsTitle.add("我报名的");
		fragmentList.add(fragment2);
		tabsTitle.add("评论我的");
		fragmentList.add(fragment3);
		tabsTitle.add("我推荐的");

		viewPager.setAdapter(new CustomFragmentPagerAdapter(getChildFragmentManager(), tabsTitle, fragmentList));

		tabLayout.setupWithViewPager(viewPager);
		tabLayout.setTabMode(TabLayout.MODE_FIXED);
		tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

		viewPager.setOffscreenPageLimit(2);
		return rootView;
	}
}
